package com.cn.kehong.controller;


import com.cn.kehong.api.ISysInfoService;
import com.cn.kehong.domain.SysInfo;
import com.cn.kehong.utils.JsonResponse;
import com.cn.kehong.utils.QueryForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/sysInfo")
public class SysInfoController {

    @Autowired
    private ISysInfoService sysInfoService;
    @ResponseBody
    @RequestMapping("/getSysInfoList")
    public JsonResponse<SysInfo> getSysInfoList(QueryForm queryForm) throws Exception {
        JsonResponse<SysInfo> response = new JsonResponse<SysInfo>();
        SysInfo sysInfos = sysInfoService.getSysInfoList(queryForm);
        response.setResult(sysInfos);
        response.setSuccess(true);
        return response;
    }

    @ResponseBody
    @RequestMapping("/addOrUpdateSysInfo/{frontToken}")
    public JsonResponse<String> addOrUpdateSysInfo(SysInfo sysInfo,@PathVariable(value = "frontToken",required = true) String frontToken) throws Exception {
        JsonResponse<String> response = new JsonResponse<String>();
        String result = sysInfoService.addOrUpdateSysInfo(sysInfo);
        response.setSuccess(true);
        response.setResult(result);
        return response;
    }

    @ResponseBody
    @RequestMapping("/updateSysInfo/{frontToken}")
    public JsonResponse<String> updateSysInfo(SysInfo sysInfo,@PathVariable(value = "frontToken",required = true) String frontToken) throws Exception {
        JsonResponse<String> response = new JsonResponse<String>();
        String result = sysInfoService.updateSysInfo(sysInfo);
        response.setResult(result);
        response.setSuccess(true);
        return response;
    }

    @ResponseBody
    @RequestMapping("/api/getSysInfoList")
    public JsonResponse<SysInfo> getApiSysInfoList(QueryForm queryForm) throws Exception {
        JsonResponse<SysInfo> response = new JsonResponse<SysInfo>();
        SysInfo sysInfos = sysInfoService.getApiSysInfoList(queryForm);
        response.setResult(sysInfos);
        response.setSuccess(true);
        return response;
    }



}
